/**
 * 
 */
package com.platform.template.qiniu;

import java.util.List;

/**
 * <pre>
 * 功能：七牛视频信息解析类
 * </pre>
 * @author wei.gao
 */
public class VideoInfo {
	public VideoInfoFormat format;
	public List<VideoStream> streams;

	public SelfVideoInfo info(){
		SelfVideoInfo info = new SelfVideoInfo();
		if(format != null){
			info.duration = Double.valueOf(Double.valueOf(format.duration)*1000).longValue();
			info.size = Long.valueOf(format.size);
		}
		if(streams != null){
			for (VideoStream st : streams) {
				if("audio".equals(st.codec_type)){
					info.hasAudio = true;
				}else if("video".equals(st.codec_type)){
					info.width = Integer.valueOf(st.width);
					info.height = Integer.valueOf(st.height);
				}
			}
		}
		return info;
	}
	
	public class VideoStream{
		public String codec_type;
		public String width;
		public String height;
	}
	
	public class VideoInfoFormat{
		public String duration;
		public String size;
	}
	
	public static class SelfVideoInfo{
		public long duration = 0;
		public int width = 0;
		public int height = 0;
		public long size = 0;
		public boolean hasAudio = false;
	}
}
